using namespace System;
using namespace System::Collections::ObjectModel;
using namespace System::Runtime::InteropServices;
class CPPNetHelper
{
public:
	static Dictionary<System::String^,System::String^>^   ToNetMap(const std::map<tstring,tstring>& _map)
	{
		Dictionary<System::String^,System::String^>^ ret = gcnew Dictionary<System::String^,System::String^>();

		for(std::map<tstring,tstring>::const_iterator it = _map.begin(); it!= _map.end(); ++it)
		{
			System::String^ key = gcnew System::String (it->first.c_str());
			System::String^ val = gcnew System::String (it->second.c_str());
			ret[key] = val;
		}
		return ret;
	}

	static    std::map<tstring,tstring>  ToMap(Dictionary<System::String^,System::String^>^ input)
	{
		std::map<tstring,tstring> ret;
		
		

		for each(KeyValuePair<System::String^, System::String^>^ item in input)
		{
			const wchar_t* chars = (const wchar_t*)(Marshal::StringToHGlobalUni(item->Key)).ToPointer();
			std::wstring os = chars;
			Marshal::FreeHGlobal(System::IntPtr((void*)chars));


			const wchar_t* chars1 = (const wchar_t*)(Marshal::StringToHGlobalUni(item->Value)).ToPointer();
			std::wstring os1 = chars1;
			Marshal::FreeHGlobal(System::IntPtr((void*)chars1));

			tstring key = UStrConvUtils::ToTS(os);
			tstring val = UStrConvUtils::ToTS(os1);

			
			ret[key] = val;
		}
		return ret;
	}


	static ResultF403^ ToNetF403(const PositionInfo& info)
	{
		ResultF403^ ret = gcnew ResultF403();
		ret->cost_price =info.cost_price;
		ret->current_amount=info.current_amount;
		ret->enable_amount=info.enable_amount;
		ret->income_balance=info.income_balance;
		ret->last_price=info.last_price;
		ret->market_value=info.market_value;


		ret->stock_code=gcnew System::String (info.code.c_str() );
		ret->stock_name=gcnew System::String (info.stock_name.c_str());
		return ret;
	}



	static ResultF402^ ToNetResultF402(const DealedOrder& order)
	{
		ResultF402^ res = gcnew ResultF402();

		res->bs_name = gcnew System::String( order.bs_name.c_str() );
		res->business_amount = order.business_amount;
		res->business_balance = order.business_balance;
		res->business_price = order.business_price;
		res->business_status = gcnew System::String(order.business_status.c_str());
		res->business_time = order.business_time;
		res->business_times = order.business_times;
		res->business_type = gcnew System::String(order.business_type.c_str());
		res->date = order.date;
		res->entrust_bs =(Tigera::T_Definition::EntrustBs)  order.entrust_bs;
		res->entrust_no = order.entrust_no;
		res->exchange_type = gcnew System::String(order.exchange_type.c_str());

		res->report_no = order.report_no;
		res->serial_no = order.serial_no;
		res->status_name = gcnew System::String( order.status_name.c_str() );
		res->stock_account = gcnew System::String(order.stock_account.c_str());
		res->stock_code = gcnew System::String(order.stock_code.c_str());
		res->stock_name = gcnew System::String(order.stock_name.c_str());
		res->type_name = gcnew System::String(order.type_name.c_str());
		return res;
	}



	static NetBasicAccountInfo^ ToNetBasicAccountInfo(const BasicAccountInfo& input)
	{
		NetBasicAccountInfo^ ret = gcnew NetBasicAccountInfo();
		ret->	AssetBalance = 		 input.AssetBalance;
		ret->		ClientName=		gcnew System::String(input.ClientName.c_str());
		ret->	CurrentBalance=	input.CurrentBalance;
		ret->EnableBalance=	input.EnableBalance;
		ret->FetchCash=	input.FetchCash;
		ret->FundAccount=gcnew System::String(	input.FundAccount.c_str());
		ret->MoneyType=	gcnew System::String(input.MoneyType.c_str());
		ret->SHStockAccount=	gcnew System::String(input.SHStockAccount.c_str());
		ret->SZStockAccount=	gcnew System::String(input.SZStockAccount.c_str());
		return ret;
	}

};

